<link rel="stylesheet" href="<%- Virtual_Path.Static %>main/css/forget.css">
<div class="xiu-container">
    <div class="forget-main">
        <div class="forget-t">
            <h1>找回密码</h1>
        </div>
        <div class="forget-m">
            <div class="group-content">
                <div class="group-item">
                    <input type="password" name="newpwds" value="" placeholder="请输入新密码" class="input">
                </div>
                <div class="group-item">
                    <input type="password" name="twonewpwds" value="" placeholder="请再次输入" class="input">
                </div>
                <div class="group-item">
                    <input type="button" id="J_UserPassword_Forgot_sub" class="button-normal button-next" value="下一步">
                </div>
            </div>

        </div>
    </div>
</div>

<script>
    $(function () {
        if (_StateData.IsLogin) {
            $.CommonMain.Modal_Tip('用户已经登录', {Timeout: 1000});
            location.href = '/';
        }
        $('#J_UserPassword_Forgot_sub').on('click', function () {
            var params = {};
            params.Password = $.trim($('input[name="newpwds"]').val());
            params.PasswordTwo = $.trim($('input[name="twonewpwds"]').val());
            params.Phone = _PageData.Phone;
            if (params.PasswordTwo != params.Password) {
                $.CommonMain.Modal_Tip('你输入的两次密码不一致，请重新输入', {Timeout: 2000});
                $('input[name="newpwds"]').focus();
                return false;
            }
            if (params.Password.length < 4 || params.Password.length > 12) {
                $.CommonMain.Modal_Tip('请输入4～12字符密码', {Timeout: 2000});
                $('input[name="newpwds"]').focus();
                return false;
            }
            $.KOC.Loading.Open();
            $.ajax({
                url: '/ajax/user.user-info.updatepassword',
                type: 'post',
                dataType: 'json',
                data: {
                    Phone: params.Phone,
                    Password: md5(params.Password)
                },
                success: function (data) {
                    $.KOC.Loading.Close();
                    if (data.flag !== 0) {
                        $.CommonMain.Modal_Tip(data.msg + "(" + data.flag + ")", {Timeout: 2000});
                        return;
                    }
                    $.CommonMain.Modal_Tip('密码设置成功', {
                        Timeout: 1000,
                        onClose: function () {
                            $.Common.ModalWindow.fnEnter();
                            location.href = '/';
                        }
                    });
                }
            });
        });
    });
</script>